package com.example.myapplication;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.myapplication.dao.PersonDao;
import com.example.myapplication.model.Person;

@Database(entities = {Person.class},version = 1,exportSchema = false)
public abstract class PersonDatabase extends RoomDatabase {


    private static PersonDatabase INSTANCE;

    public static synchronized PersonDatabase getDatabase(Context c){
        if (INSTANCE==null){
            INSTANCE=Room.databaseBuilder(c.getApplicationContext(),PersonDatabase.class,"person_database")
                    .allowMainThreadQueries()
                    .build();
        }
        return INSTANCE;
    }

    public abstract PersonDao getPersonDao();
}
